# the minimum version of CMake.
cmake_minimum_required(VERSION 3.5)
project(openssl_napi)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-int-conversion -Wl,-Bsymbolic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-int-conversion -Wl,-Bsymbolic")
set(CMAKE_SKIP_RPATH TRUE)

add_definitions(-DOHOS_PLATFORM -D__OHOS__)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug")
endif()

add_definitions(-DOHOS_LOG_TAG=\"openssl_napi\")
add_subdirectory(ohos_utils)

add_library(openssl_napi SHARED openssl_napi.cpp)

set(OPENSSL_ROOT_DIR ${CMAKE_SOURCE_DIR}/thirdparty/openssl/${OHOS_ARCH})
set(OPENSSL_INCLUDE_DIR ${OPENSSL_ROOT_DIR}/include)
set(OPENSSL_LIBRARY_DIR ${OPENSSL_ROOT_DIR}/lib)

target_link_libraries(openssl_napi PUBLIC ohos_utils ${OPENSSL_LIBRARY_DIR}/libssl.a ${OPENSSL_LIBRARY_DIR}/libcrypto.a)
target_include_directories(openssl_napi PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${OPENSSL_INCLUDE_DIR})
target_compile_options(openssl_napi PRIVATE -Wno-changes-meaning -Wno-int-conversion)
